﻿using Super_Management_Mayhem.Screens.Playing.Players;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.AttackModel
{
    public abstract class BaseAttack
    {
        public enum TargetTeam
        {
            AlliedTo,
            EnemyTo,
            Any,
        }

        private TargetTeam _targetType;
        private Team _targetTeam;
        protected IAttacker Attacker;
        protected TE_Rectangle AttackBoundingBox;

        protected int Damage;

        protected int HurtTime;

        public BaseAttack(TargetTeam targetType, Team targetTeam, IAttacker attackerObject, int damage, int hurtTime, TE_Rectangle attackBoundingBox)
        {
            _targetType = targetType;
            _targetTeam = targetTeam;
            Attacker = attackerObject;
            Damage = damage;
            AttackBoundingBox = attackBoundingBox;
            HurtTime = hurtTime;
        }

        protected bool IsValidTarget(IAttackable possibleTarget)
        {
            if (possibleTarget == Attacker)
                return false;

            switch (_targetType)
            {
                case TargetTeam.AlliedTo:
                    return possibleTarget.GetTeam() == _targetTeam;
                case TargetTeam.EnemyTo:
                    return possibleTarget.GetTeam() == null || possibleTarget.GetTeam() != _targetTeam;
                case TargetTeam.Any:
                    return true;
            }

            return false;
        }

        public abstract bool Attack(IAttackable possibleTarget);
        public abstract void Attack(TE_Vector2 position);

        public void RemoveTeam()
        {
            _targetType = TargetTeam.Any;
        }
    }
}